package descentFly.app.sight
{
	import UIAway.uif_view;
	
	import UIFree.uif_component;
	import UIFree.uif_transition;
	
	import descentFly.app.df_component;
	import descentFly.away3D4.chips.df_chipAway;
	import descentFly.df_spaceObject;
	import descentFly.view.df_view;
	
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Vector3D;
	
	public class df_targetRing extends df_component {
		private var _hitObject	: df_chipAway;
		private var _view		: uif_view;
		private var _show		: Number;
		private var _ring		: df_ring;
		public function df_targetRing(parent:uif_component, a_view: uif_view, a_radius: Number, styleClass:Object='') {
			super(parent, 0, 0, a_radius, a_radius, styleClass);
			_show = 0; 
			_ring = new df_ring(this, a_radius, 'ring');
			_ring.visible = false;
			_view = a_view;
		}
		
		public function hitObject(a_hitObject: df_chipAway, distance: Number=0): void {
			if (a_hitObject != _hitObject) {
				_hitObject = a_hitObject; 
				fx('show', show, _hitObject?1:0, uif_transition.easeIn(uif_transition.Bounce, 2)).start();
			}
			if (_hitObject) {
				position = _view.position.add(_view.view.project(_hitObject.body.currentState.position));
				_ring.destanceLabel = Math.round(distance).toString();
			}
		}
		
		public function set show(a_set: Number): void {
			_show = a_set;
			_ring.visible = _show > 0;
			_ring.alpha = _show;
//			alpha = visible?1:0;
			_ring.rotation = (1 - _show) * 90;
			_ring.scale = 1 + ((1 - _show) * 0.5);
		}
		
		public function get show(): Number {
			return _show;
		}
	}
}